package java_DesignPattern.BehavioralPattern.MediatorPattern;

/**
 * 房屋中介类，实现了Mediator接口
 */
public class HouseMediator extends Mediator {

    private Tenant tenant;

    private HouseOwner houseOwner;

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    @Override
    public void contact(String message, Person person) {
        if (person instanceof Tenant) {
            houseOwner.getMessage(message);
        } else if (person instanceof HouseOwner) {
            tenant.getMessage(message);
        }
    }
}
